package VehicleCommServer;

import java.io.FileInputStream;
import java.util.Properties;

/**
 * <pre>
 * @Package : VehicleCommServer
 * @File    : ConfigManager.java
 * <pre>
 *
 * @Author  : 차재우
 * @Date    : 2013. 7. 24.
 * @Version :
 */
public class ConfigManager {
	private Properties p = null;
	
	private String serialPort = null;
	private String serverIp = null;
	private int serverPort = 0;

	/**
	 * <pre>
	 * @Comment : 생성자
	 * <pre>
	 *
	 */
	public ConfigManager() {
		p = new Properties();
		
		ParseIni();
	}

	/**
	 * <pre>
	 * @Comment : INI 파일 정보 파싱
	 * <pre>
	 *
	 * @Method  : ParseIni
	 */
	private void ParseIni() {
		try {
			String currentDir = System.getProperty("user.dir") + "/INI/config.ini";
			p.load(new FileInputStream(currentDir));

			this.serverIp = p.getProperty("vcsip");
			this.serverPort = Integer.parseInt(p.getProperty("vcstcpport"));
			this.serialPort = p.getProperty("vcsserialport");
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	
	/**
	 * <pre>
	 * @Comment : 파싱정보 출력
	 * <pre>
	 *
	 * @Method  : toString
	 * @return
	 */
	public String toString()
	{
		String str = "==============================================\n" +
					 " Server ip   : " + this.serverIp + "\n" +
					 " Server port : " + this.serverPort + "\n" +
					 " Serial port : " + this.serialPort + "\n" +
					 "==============================================";

		return str;
	}

	/**
	 * @return the serverIp
	 */
	public String getServerIp() {
		return serverIp;
	}

	/**
	 * @return the serverPort
	 */
	public int getServerPort() {
		return serverPort;
	}

	/**
	 * @return the serialPort
	 */
	public String getSerialPort() {
		return serialPort;
	}
}
